package designPattern.builder;

import java.util.UUID;

/**
 * 邮件类建造者
 * @author zhaohuihbwj
 */
public class MailBuilder {

    private Mail mail = null;

    public MailBuilder buildMail(){
        mail = new Mail();
        String id = UUID.randomUUID().toString().toUpperCase().replace("-", "");
        mail.setId(id);
        return this;
    }

    public MailBuilder buildFrom(String from){
        mail.setFrom(from);
        return this;
    }

    public MailBuilder buildTo(String to){
        mail.setTo(to);
        return this;
    }

    public MailBuilder buildSubject(String subject){
        mail.setSubject(subject);
        return this;
    }

    public MailBuilder buildContent(String content){
        mail.setContent(content);
        return this;
    }

    public Mail toMail(){
        return mail;
    }
}
